<?php

/**
 * urCronPluginConfiguration Class
 *
 * @package    urCronPlugin
 * @version    $Id: urCronPluginConfiguration.class.php 12 2009-06-10 15:29:28Z flambeur $
 */
class urCronPluginConfiguration extends sfPluginConfiguration
{
  static protected $HTMLPurifierLoaded = false;

  public function initialize()
  {
    // code derived from the config.php of sfDoctrineGuardPlugin
    if(sfConfig::get('ur_cron_prepend_routes', true))
    {
      $this->dispatcher->connect('routing.load_configuration', array('urCronRouting', 'addRouteForFrontend'));
    }

    foreach(array('adminUrCronFeed', 'adminUrCronItem', 'adminUrCronTag') as $module)
    {
      if(in_array($module, sfConfig::get('sf_enabled_modules', array())))
      {
        $this->dispatcher->connect('routing.load_configuration', array('urCronRouting', 'addRouteForAdmin'.str_replace('adminUrCron', '', $module)));
      }
    }
  }

  static public function enableUrCronPlugins(ProjectConfiguration $configuration)
  {
    $pluginPath = dirname(dirname(__FILE__)).'/plugins';
    $plugins = sfFinder::type('dir')->name('*Plugin')->in($pluginPath);
    foreach($plugins as $plugin)
    {
      $configuration->setPluginPath(str_replace($pluginPath.'/', '', $plugin), $plugin);
    }
  }
	
	static public function registerHTMLPurifier()
  {
    if(self::$HTMLPurifierLoaded)
      return;

    spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'));
    self::$HTMLPurifierLoaded = true;
  }
}